﻿using Acms.SqlDal;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections;
using System.Data.SqlClient;

namespace SqlDalTests
{
    
    
    /// <summary>
    ///This is a test class for PostDalTest and is intended
    ///to contain all PostDalTest Unit Tests
    ///</summary>
    [TestClass()]
    public class PostDalTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetTopLevelBySiteId
        ///</summary>
        [TestMethod()]
        public void GetTopLevelBySiteIdTest()
        {
            PostDal target = new PostDal();
            int siteId = 1;
            Nullable<DateTime> siteVersion = new Nullable<DateTime>();

            Hashtable actual;
            actual = target.GetTopLevelBySiteId(siteId, siteVersion);

            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for GetBySiteUrlAndPostUrl
        ///</summary>
        [TestMethod()]
        public void GetBySiteUrlAndPathTestNoEndingSlash()
        {
            PostDal target = new PostDal();
            string siteUrl = "www.reservesociety.com";
            string path = "~/Issues";
            DateTime? siteVersion = null;
            Hashtable actual;
            actual = target.GetBySiteUrlAndPath(siteUrl, path, siteVersion);
            Assert.IsNotNull(actual);
        }

        [TestMethod()]
        public void GetBySiteUrlAndPathTestEndingSlash()
        {
            PostDal target = new PostDal();
            string siteUrl = "www.reservesociety.com";
            string path = "~/Issues/";
            DateTime? siteVersion = null;
            Hashtable actual;
            actual = target.GetBySiteUrlAndPath(siteUrl, path, siteVersion);
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for GetBySiteIdAndPath
        ///</summary>
        [TestMethod()]
        public void GetBySiteIdAndPathTestNoEndingSlash()
        {
            PostDal target = new PostDal();
            int siteId = 1;
            string path = "~/Issues";
            Nullable<DateTime> siteVersion = new Nullable<DateTime>();
            Hashtable actual;
            actual = target.GetBySiteIdAndPath(siteId, path, siteVersion);
            Assert.IsNotNull(actual);
        }

        [TestMethod()]
        public void GetBySiteIdAndPathTestEndingSlash()
        {
            PostDal target = new PostDal();
            int siteId = 1;
            string path = "~/Issues/";
            Nullable<DateTime> siteVersion = new Nullable<DateTime>();
            Hashtable actual;
            actual = target.GetBySiteIdAndPath(siteId, path, siteVersion);
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for GetByPostGuid
        ///</summary>
        [TestMethod()]
        public void GetByPostGuidTest()
        {
            PostDal target = new PostDal();
            Guid postGuid = new Guid("DB8FA5CF-C73E-4969-9B32-A7E4C3FA711E");
            Nullable<DateTime> siteVersion = new Nullable<DateTime>();

            Hashtable actual;
            actual = target.GetByPostGuid(postGuid, siteVersion);
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for GetById
        ///</summary>
        [TestMethod()]
        public void GetByIdTest()
        {
            PostDal target = new PostDal(); // TODO: Initialize to an appropriate value
            int id = 3;
            Nullable<DateTime> siteVersion = new Nullable<DateTime>(); // TODO: Initialize to an appropriate value
            Hashtable actual;
            actual = target.GetById(id, siteVersion);
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for GetAllByTopicId
        ///</summary>
        [TestMethod()]
        public void GetAllByTopicIdTest()
        {
            PostDal target = new PostDal();
            int topicId = 5;
            Nullable<DateTime> siteVersion = new Nullable<DateTime>(); // TODO: Initialize to an appropriate value
            Hashtable[] actual;
            actual = target.GetAllByTopicId(topicId, siteVersion);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
        }

        /// <summary>
        ///A test for GetAllBySiteIdParentPath
        ///</summary>
        [TestMethod()]
        public void GetAllBySiteIdAndParentPathTestNoEndingSlash()
        {
            PostDal target = new PostDal();
            int siteId = 1;
            string parentPath = "~/Issues";
            DateTime? siteVersion = null;
            Hashtable[] actual;
            actual = target.GetAllBySiteIdAndParentPath(siteId, parentPath, siteVersion);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
        }

        public void GetAllBySiteIdAndParentPathTestEndingSlash()
        {
            PostDal target = new PostDal();
            int siteId = 1;
            string parentPath = "~/Issues/";
            DateTime? siteVersion = null;
            Hashtable[] actual;
            actual = target.GetAllBySiteIdAndParentPath(siteId, parentPath, siteVersion);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
        }

        /// <summary>
        ///A test for GetAllBySiteIdMenuIdAndParentPath
        ///</summary>
        [TestMethod()]
        public void GetAllBySiteIdMenuIdAndParentPathTestNoEndingSlash()
        {
            PostDal target = new PostDal();
            int siteId = 1;
            int menuId = 1;
            string parentPath = "~/Issues";
            Nullable<DateTime> siteVersion = new Nullable<DateTime>();

            Hashtable[] actual;
            actual = target.GetAllBySiteIdMenuIdAndParentPath(siteId, menuId, parentPath, siteVersion);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
        }


        /// <summary>
        ///A test for GetAllBySiteIdMenuIdAndParentPath
        ///</summary>
        [TestMethod()]
        public void GetAllBySiteIdMenuIdAndParentPathTestEndingSlash()
        {
            PostDal target = new PostDal();
            int siteId = 1;
            int menuId = 1;
            string parentPath = "~/Issues/";
            Nullable<DateTime> siteVersion = new Nullable<DateTime>();

            Hashtable[] actual;
            actual = target.GetAllBySiteIdMenuIdAndParentPath(siteId, menuId, parentPath, siteVersion);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
        }
        
        /// <summary>
        ///A test for GetAllByParentIdAndTopicId
        ///</summary>
        [TestMethod()]
        public void GetAllByParentGuidAndTopicIdTestNotIncludingChildren()
        {
            PostDal target = new PostDal();
            Guid parentGuid = new Guid("DB8FA5CF-C73E-4969-9B32-A7E4C3FA711E");
            int topicId = 5;
            DateTime? siteVersion = null;
            bool includeChildren = false;
            int startIndex = 0;
            int pageSize = 0;
            int totalRecords = 0;

            Hashtable[] actual;
            actual = target.GetAllByParentGuidAndTopicId(parentGuid, topicId, siteVersion, includeChildren, startIndex, pageSize, ref totalRecords);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
            Assert.AreEqual(totalRecords, actual.Length);
        }

        /// <summary>
        ///A test for GetAllByParentIdAndTopicId
        ///</summary>
        [TestMethod()]
        public void GetAllByParentGuidAndTopicIdTestIncludingChildren()
        {
            PostDal target = new PostDal();
            Guid parentGuid = new Guid("DB8FA5CF-C73E-4969-9B32-A7E4C3FA711E");
            int topicId = 5;
            DateTime? siteVersion = null;
            bool includeChildren = true;
            int startIndex = 0;
            int pageSize = 0;
            int totalRecords = 0;

            Hashtable[] actual;
            actual = target.GetAllByParentGuidAndTopicId(parentGuid, topicId, siteVersion, includeChildren, startIndex, pageSize, ref totalRecords);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
            Assert.AreEqual(totalRecords, actual.Length);
        }

        /// <summary>
        ///A test for GetAllByParentIdAndTopicId
        ///</summary>
        [TestMethod()]
        public void GetAllByParentGuidAndTopicIdTestPaging()
        {
            PostDal target = new PostDal();
            Guid parentGuid = new Guid("DB8FA5CF-C73E-4969-9B32-A7E4C3FA711E");
            int topicId = 5;
            DateTime? siteVersion = null;
            bool includeChildren = true;
            int startIndex = 0;
            int pageSize = 2;
            int totalRecords = 0;

            Hashtable[] actual;
            actual = target.GetAllByParentGuidAndTopicId(parentGuid, topicId, siteVersion, includeChildren, startIndex, pageSize, ref totalRecords);
            Assert.IsNotNull(actual);
            Assert.AreEqual(2, actual.Length);
            Assert.IsTrue(totalRecords > actual.Length);
        }


        /// <summary>
        ///A test for GetAllByParentGuid
        ///</summary>
        [TestMethod()]
        public void GetAllByParentGuidTest()
        {
            PostDal target = new PostDal();
            Guid parentGuid = new Guid("DB8FA5CF-C73E-4969-9B32-A7E4C3FA711E");
            Nullable<DateTime> siteVersion = new Nullable<DateTime>();

            Hashtable[] actual;
            actual = target.GetAllByParentGuid(parentGuid, siteVersion);

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
        }

        /// <summary>
        ///A test for GetAllByMenuIdAndParentGuid
        ///</summary>
        [TestMethod()]
        public void GetAllByMenuIdAndParentGuidTest()
        {
            PostDal target = new PostDal();
            int menuId = 4;
            Guid parentGuid = new Guid("DB8FA5CF-C73E-4969-9B32-A7E4C3FA711E");
            Nullable<DateTime> siteVersion = new Nullable<DateTime>(); // TODO: Initialize to an appropriate value

            Hashtable[] actual;
            actual = target.GetAllByMenuIdAndParentGuid(menuId, parentGuid, siteVersion);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
        }
    }
}
